package com.demo.controller;

import com.demo.entity.VtePreventiveDoctorAdvice;
import com.demo.response.Result;
import com.demo.service.IVtePreventiveDoctorAdviceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * vte预防处置医嘱 前端控制器
 *
 * @author zm
 * @since 2020-11-27
 */
@Api(tags = "vte预防处置医嘱")
@RestController
@RequestMapping("/vtePreventiveDoctorAdvice")
public class VtePreventiveDoctorAdviceController {
    @Autowired
    IVtePreventiveDoctorAdviceService adviceService;

    @ApiOperation("防治医嘱更新")
    @PostMapping("/invalidDoctorAdvice")
    public Result invalidDoctorAdvice(@RequestBody VtePreventiveDoctorAdvice doctorAdvice) throws Exception {
        return adviceService.invalidDoctorAdvice(doctorAdvice);
    }

    @ApiOperation("防治医嘱列表")
    @GetMapping("/doctorAdviceList")
    public Result doctorAdviceList(@RequestParam(name = "pageNumber", required = false, defaultValue = "1") Integer pageNumber,
                                   @RequestParam(name = "pageSize", required = false, defaultValue = "10") Integer pageSize,
                                   @RequestParam(name = "patientId", required = false) Integer patientId,
                                   @RequestParam(name = "adviseType", required = false) Integer adviseType,
                                   @RequestParam(name = "status", required = false) Integer status,
                                   @RequestParam(name = "validityLength", required = false) Integer validityLength) {
        return adviceService.doctorAdviceList(pageNumber, pageSize, patientId, adviseType, status, validityLength);
    }

    @Deprecated
    @ApiOperation(value = "防治医嘱列表--2")
    @GetMapping("/doctorAdviceListTwo")
    public Result doctorAdviceListTwo(@RequestParam(name = "pageNumber", required = false, defaultValue = "1") Integer pageNumber,
                                      @RequestParam(name = "pageSize", required = false, defaultValue = "10") Integer pageSize,
                                      @RequestParam(name = "patientId", required = false) Integer patientId,
                                      @RequestParam(name = "adviseType", required = false) Integer adviseType,
                                      @RequestParam(name = "status", required = false) Integer status,
                                      @RequestParam(name = "validityLength", required = false) Integer validityLength) {
        return adviceService.doctorAdviceListTwo(pageNumber, pageSize, patientId, adviseType, status, validityLength);
    }

    @ApiOperation(value = "vte的物理IPC列表", tags = {"vte预防处置医嘱", "v20210419更新"})
    @GetMapping("vtePreventiveIpcList")
    public Result vtePreventiveIpcList(@RequestParam(name = "pageNumber", required = false, defaultValue = "1") Integer pageNumber,
                                       @RequestParam(name = "pageSize", required = false, defaultValue = "5") Integer pageSize,
                                       @RequestParam(name = "wardId", required = false) String wardId) {
        return adviceService.doctorIpcAdviceByWardId(1, 5, wardId);
    }

    @ApiOperation(value = "VTE评估医嘱增量单列值更新", tags = {"VTE评估", "v20210427更新"}, notes = "仅只支持preventive_risk_result,preventive_risk_advise,preventive_taboo_result,preventive_taboo_advise,other_prevention维度更新")
    @PostMapping({"/updateVtePreventtiveAdviceInfoByKey"})
    @ApiImplicitParams({@ApiImplicitParam(name = "doctorAdviceId", value = "医嘱处理编号"), @ApiImplicitParam(name = "updateKey", value = "更新的键"), @ApiImplicitParam(name = "updateValue", value = "更新的值")})
    public Result updateVtePreventiveAdviceInfoByKey(@RequestParam(name = "doctorAdviceId", required = true) Integer doctorAdviceId, @RequestParam(name = "updateKey", required = true) String updateKey, @RequestParam(name = "updateValue", required = true) String updateValue) throws Exception {
        this.adviceService.updateVtePreventiveAdviceInfoByKey(doctorAdviceId, updateKey, updateValue);
        return Result.success();
    }

    @ApiOperation(value = "获取 VTE 评估医嘱自定义维度信息", tags = {"VTE评估", "v20210427更新"}, notes = "按键获取评估维度信息，病人 ID 号或者医嘱 ID 号必须传一个")
    @GetMapping({"/getVtePreventtiveAdviceInfoByKey"})
    @ApiImplicitParams({@ApiImplicitParam(name = "doctorAdviceId", value = "医嘱处理编号"), @ApiImplicitParam(name = "patientId", value = "病人 ID 号"), @ApiImplicitParam(name = "adviseType", value = "医嘱类型 1 药物 2 物理"), @ApiImplicitParam(name = "getKey", value = "更新的键")})
    public Result getVtePreventiveAdviceInfoByKey(@RequestParam(name = "doctorAdviceId", required = false) Integer doctorAdviceId, @RequestParam(name = "patientId", required = false) Integer patientId, @RequestParam(name = "adviseType", required = false) Integer adviseType, @RequestParam(name = "getKey", required = true) String getKey) throws Exception {
        return this.adviceService.getVtePreventiveAdviceInfoByKey(doctorAdviceId, patientId, adviseType, getKey);
    }

    @ApiOperation(value = "获取相关评率的药物的提醒", tags = {"VTE评估", "v20210507更新"}, notes = "测试定时任务使用")
    @ApiImplicitParams({@ApiImplicitParam(name = "wayGap", value = "提醒频率 Qd,Bid,Tid,Q8h,Qn")})
    @GetMapping({"/getDvtTask"})
    public Result getVteTask(@RequestParam(name = "wayGap", required = true) String wayGap) throws Exception {
        return Result.success(this.adviceService.getMedicinePreventiveInterval(wayGap));
    }

}
